#ifndef _LIST_H_
#define _LIST_H_

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct list_head
{
	struct list_head *prev;
	struct list_head *next;
};

typedef struct list_head list_t;

#define list_entry(node, type, member) \
    ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member)))


static __inline__
void list_init(list_t *l)
{
	l->next = l->prev = l;
}


static __inline__
void list_add(list_t *l, list_t *n)
{
	list_t *next = l->next;
	
	n->next = l->next;
	n->prev = l;
	l->next = n;
	next->prev = n;
}


static __inline__
void list_add_tail(list_t *l, list_t *n)
{
	n->prev = l->prev;
	n->next = l;

	l->prev->next = n;
	l->prev = n;
}

static __inline__
void list_del(list_t *n)
{
	n->prev->next = n->next;
	n->next->prev = n->prev;
}


#endif /*_LIST_H_*/

